<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <div class="box">
        <p>11</p>
        <h3>22</h3>
        <h4>444</h4>
    </div>

    <script>

        // replaceChild()  替换指定的子元素



        var oBox = document.querySelector('div');
        var oP = document.querySelector('p');

        var oH2 = document.createElement('h2');
        oH2.innerHTML = '我是新来的';

        oBox.replaceChild(oH2, oP);


    </script>

</body>

</html>